home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / speller2.zip / SPELL.DOC < prev    next >
Text File  |  1995-02-25  |  5KB  |  119 lines

  1.                             The Speller
  2.      Copyright (c) 1994, The Yucatan Electronic Assembly Company.
  3.  
  4. This document covers the basic functions needed to use the speller.
  5. A complete class reference will be available soon and will be mailed
  6. to registered users.
  7.  
  8. Files:
  9.    
  10.    README.DOC       - Read This File.    SPELLER.CPP      - Demo Program to test the library    SPELLER.EXE      - Compiled version of speller.cpp
  11.    SPELL.DOC        - This File. (Also Includes simple demo)    MAIN.DIC         - The main dictionary file.    MAIN.INX         - The index file for the dictionary.    USER.DIC         - Fast Dictionary file   SPELL.HPP        - Header, Include this in youre source.    SPELL.LIB        - Speller Library. Borland large memory model.
  12.                       We will soon have support for other compilers. Send
  13.                       me e-mail if you need a version for another compiler.   XMS.H            - used by spell.hpp    EMS.H            - used by spell.hpp
  14.    XMM.H            - used by spell.hpp
  15.    SPOBJS.H         - used by spell.hpp
  16.  
  17. Note: The dictionary files should be in the same directory as the .exe
  18.  
  19. The following classes are provided:
  20.  
  21.      spell     - this is the base spell class.
  22.      XmsSpell  - store dictionary in XMS memory
  23.      CXmsSpell - store dictionary in XMS memory and use compression
  24.      DiskSpell - store dictionary on disk
  25.  
  26. Note: Most debuggers will not work with programs that use XMS memory. 
  27.       Use DiskSpell while debugging then switch to a faster class for distribution.
  28.   
  29.  
  30. Each of the classes have the same primary function derived from spell. You may use 
  31. spell as a pointer to the other three classes. This allows your program to change the 
  32. storage method at run time.
  33.  
  34. The following functions are common to all classes:
  35.  
  36. int check(char *);      - Returns 1 if the spelling is verified, otherwise
  37.                           it returns 0.  This function checks to see
  38.                           if a word is spelled correctly.
  39.  
  40. int getLastError();     - Returns 0 if no errors have occured
  41.                           this function should be called after the constructor
  42.                           to be sure that no file errors have happened.
  43.  
  44. void SetLevel(int);     - This function sets which suggestion algorithm to use.
  45.                           COMPLEX_MATCH generates the best list of suggestions
  46.                           TYPOS_MATCH is faster but the list is not as good
  47.  
  48. int addToTempDic(char *)- This function adds the word to the dictionary.
  49.                           The word is added to a temporary dictionary and
  50.                           can be merged with the main dictionary. This allows
  51.                           words to be double checked before permanently adding
  52.                           them.  The temp.dic file can be edited with a text
  53.                           editor.
  54.  
  55. int saveTempDic()       - Saves the words added with addToTempDic() to disk.
  56.  
  57. int ignore(char *)      - This stores the word in a dictionary that is never
  58.                           saved to disk. This function is useful for making
  59.                           check() ignore some words.
  60.  
  61. int suggest(char *word);- Generate list of suggestions.
  62.                           The class suggestion which is a member of spell is used 
  63.                           to retrieve the list of suggestions. See Example.
  64.                           suggestion->count holds the number of suggestions found. 
  65.                           suggestion->get(n) returns a pointer to the n'th element 
  66.                           in the suggestion list. 
  67.  
  68.  
  69. Example:
  70.  
  71.  
  72. #include "spell.hpp"
  73. #include "iostream.h"
  74.  
  75. spell *speller;  // Use the base class for our pointer
  76.  
  77. void main(int argc,char **argv)
  78. {
  79.     char *wordToCheck = argv[1];
  80.  
  81.     //
  82.     //Use DiskSpell for debugging. Most debuggers will not work well when progrms use XMS memory
  83.     //when not debugging use one of the other two constructors for speed
  84.     //
  85.  
  86.     //speller = new XmsSpell();  // Loads default dictionary files into memory
  87.     //speller = new CXmsSpell(); // Loads and compresses default dictionary file into memory
  88.     speller = new DiskSpell();   // Opens dictionary files for reading
  89.  
  90.     if (speller->getLastError()) // Check for errors
  91.     {
  92.         cout << "error loading dictionary \n\r";
  93.         delete speller;
  94.         return;
  95.     }
  96.  
  97.     speller->SetLevel(COMPLEX_MATCH);  // Set Suggestion Level COMPLEX_MATCH (Use complex algorithm)
  98.                                        // use TYPOS_MATCH for faster simple algorithm
  99.  
  100.     if (speller->check(wordToCheck)) cout << wordToCheck << " is a correct spelling";
  101.     else //the word is mispelled generate suggestions
  102.     {
  103.         cout << "Possible correct spellings of " << wordToCheck << " are :\n\r";
  104.  
  105.         // Generate correct spelling suggestion list
  106.         speller->suggest(wordToCheck);
  107.  
  108.         // Output list of suggestions
  109.         for (int i=0; i < speller->suggestion->count; i ++)
  110.         {
  111.             // ******
  112.             //    USE SUGGESTION CLASS TO retrieve LIST OF SUGGESTIONS
  113.             //      -these are the suggestions generated by the suggest function
  114.             //
  115.             cout << speller->suggestion->get(i)->name << "\n\r";
  116.         }
  117.     }
  118. }
  119.